package demo;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GZTFrame extends JFrame {
	
	private static final int FRAME_WIDTH = 400;
	private static final int FRAME_HEIGHT = 900;
	
	
	public GZTFrame() {
		init();
	}
	
	private void init() {
		setSize(FRAME_WIDTH, FRAME_HEIGHT);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setContentPane(new DrawPanel());
		setTitle("管柱图");
		
	}
	
	class DrawPanel extends JPanel {
		
		int topLevel = 100;
		int bottomLevel = FRAME_HEIGHT - 100;
		
		@Override
		public void paint(Graphics g) {
			super.paint(g);
			g.drawLine(0, topLevel, FRAME_WIDTH, topLevel); // top line
			g.drawLine(0, bottomLevel, FRAME_WIDTH, bottomLevel); // bottom line
			g.drawLine(100, topLevel, 100, bottomLevel); // left line
			g.drawLine(FRAME_WIDTH - 100, topLevel, FRAME_WIDTH - 100, bottomLevel); // right line
			g.drawRect(100, 0, 2, 2);
			
			
		}
		
	}
	
	public static void main(String[] args) {
		GZTFrame frame = new GZTFrame();
		frame.setVisible(true);
	}

}
